/*
 * @Author: zhangxiao
 * @Email: zhangxiao0125@163.com
 * @Date: 2020-07-03 08:49:55
 * @Last Modified by:   zhangxiao
 * @Last Modified time: 2020-07-03 08:49:55
 * @Description: 资源音频播放
 */

import 'package:auto_orientation/auto_orientation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_code_framework/base/base_main_tabbar.dart';
import 'package:flutter_code_framework/base/base_widget.dart';
import 'package:flutter_code_framework/route/route_transition.dart';
import 'package:flutter_code_framework/widgets/voice_player_widget.dart';

class VoicePlayer extends BaseWidget {
  String url;
  String title;
  VoicePlayer({Key key, this.url,this.title}) : super(key: key);

  @override
  BaseWidgetState<BaseWidget> getState() {
    return _VoicePlayerState();
  }
}
class _VoicePlayerState extends BaseWidgetState<VoicePlayer> {
  @override
  Widget buildWidget(BuildContext context) {
    return WillPopScope(child:Center(
      child: VoicePlayerWidget(
          url: widget.url),
    // ignore: missing_return
    ),onWillPop:(){
        RouteTransition(BaseMainTabbarPage()).pushAndRemoveUntilTransRoute(context);
    });
  }
  
  @override
  void initState() { 
    super.initState();
      //全屏 强制横屏
    AutoOrientation.landscapeRightMode();
    //启动横屏陀螺仪
    AutoOrientation.landscapeAutoMode();
  }
  @override
  void dispose() {
    super.dispose();
    AutoOrientation.portraitDownMode();
    AutoOrientation.portraitUpMode();
  }
  @override
  void onCreate() {
     setAppTopNavBarVisible(true);
     setTopNavTitle(widget.title);
  }

  @override
  void onPause() {

  }

  @override
  void onResume() {
  }
}
